<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span{
            font-size: 30px;
            color: gray;
        }
    </style>
</head>
<body>
   <span>A</span>
   <span>B</span>
   <span>C</span>
   <span>D</span>
   <span>E</span>
   <span>F</span>

    <script>
        // 配置表 
        var config =  {A:65,B:66,C:67,D:68,E:69,F:70};
        var spanEles = document.querySelectorAll("span");
        document.onkeydown = function(e){
            var e = e || window.event;
            var keyCode =   e.keyCode;
            spanEles.forEach(function(span){
                var str = span.innerText;
                // var code = config[str];
                var code = str.charCodeAt();
                console.log("??",code);
                if(keyCode===code){
                    span.style.color = "red";
                }
            })
          



        }


    </script>
</body>
</html>